package com.system.enroll.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.system.enroll.dao.StudentDao;
import com.system.enroll.model.Student;
import com.system.util.CustomHibernateDaoSupport;

@Repository("studentDao")
public class StudentDaoImpl extends CustomHibernateDaoSupport implements
		StudentDao {

	@Override
	public void save(Student student) {
		getHibernateTemplate().save(student);

	}

	@Override
	public void update(Student student) {
		getHibernateTemplate().update(student);

	}

	@Override
	public void delete(Student student) {
		getHibernateTemplate().delete(student);

	}

	@SuppressWarnings("rawtypes")
	@Override
	public Student findByStudentById(Integer id) {
		List list = getHibernateTemplate().find("from Student where id=?", id);
		return (Student) list.get(0);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Student> findAllStudent() {
		List<Student> list = getHibernateTemplate().find("from Student");
		return list;
	}

}
